<html>
<?php
session_start();
include('class.php');

if ($_POST) {
	$db = new DB();
	$result = $db->getUser($_POST['id'],$_POST['password'],$_POST['level']);
	$db->close();
	// echo $result;
	if ($result == 1) {
        $url1 = 'User2.php';
		$url2 = 'User.php';
		// store session data
		$_SESSION['login']='y';
        $_SESSION['id']=$_POST['id'];
        $_SESSION['pass']=$_POST['password'];
        $_SESSION['level']=$_POST['level'];
        //echo "<br/>"."success";
        if($_SESSION['level']=='manager'){
            Header("Location: $url1");
        }
        else {
            Header("Location: $url2");
        }
	}else{
		echo "<script type='text/javascript' language='javascript'>
              alert('please check the password or your level');
             </script>";
			 Header('Refresh: 0.01;url=Login.html');
			 
	}
	 
	//Header("Location: $url");

}else{
	//$url = 'login.html';
	//Header("Location: $url"); 
}

?>
</html>